package com.hucheng.activity.vo;

import com.hucheng.activity.entity.UserPointDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-10
 * @Description: 返回界面数据
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserPointVO implements Serializable {
    private Integer userPointId;
    private Integer userId;
    private Integer point;
    private Integer pointUsed;
    private Integer pointExpired;
    private Integer pointFrozen;
    private Integer isDel;
    private String dateCreated;
    private String dateUpdated;

    private Integer bePointExpired;

    public static UserPointVO buildUserPointVO(final UserPointDO userPointDO) {
        if (userPointDO == null) {
            return null;
        }
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return new UserPointVO(
                userPointDO.getUserPointId(),
                userPointDO.getUserId(),
                userPointDO.getPoint(),
                userPointDO.getPointUsed(),
                userPointDO.getPointExpired(),
                userPointDO.getPointFrozen(),
                userPointDO.getIsDel(),
                dateTimeFormatter.format(userPointDO.getDateCreated().toLocalDateTime()),
                dateTimeFormatter.format(userPointDO.getDateUpdated().toLocalDateTime()),userPointDO.getBePointExpired());
    }
}
